<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    var canChoose = (groups, nums) => {
      let s = nums.join(',')
      for (let g of groups) {
        let index = s.indexOf(g.join(','))
        if (index < 0) return false
        s = s.slice(index + g.join().length + 1)
      }
      return true
    }
    console.log(canChoose(groups = [[1, 2, 3], [3, 4]], nums = [7, 7, 1, 2, 3, 4, 7, 7]))
  </script>
</body>

</html>